public class MessageFactory 
{
	public MessageFactory()
	{
		
	}
	
	static String makePosition(Client client)
	{
		return new String(	client.connectedPlayer.name + 
							MessageType.DELIMITER +
							client.connectedPlayer.position.xPosition + 
							MessageType.DELIMITER +
							client.connectedPlayer.position.yPosition);
	}
	
	static String makeAttributesForForeign(Client client)
	{
		StringBuilder builder = new StringBuilder();
		for (Attribute attrib : client.connectedPlayer.attributes) 
		{
			if(attrib.visibleForOthers)
			{
				builder.append(MessageType.DELIMITER);
				builder.append(attrib.name);
				builder.append(MessageType.DELIMITER);
				builder.append(attrib.value);
			}
		}
		return builder.toString();
	}
	
	static String makeAttributesForSelf(Client client)
	{
		StringBuilder builder = new StringBuilder();
		for (Attribute attrib : client.connectedPlayer.attributes) 
		{
				builder.append(MessageType.DELIMITER);
				builder.append(attrib.name);
				builder.append(MessageType.DELIMITER);
				builder.append(attrib.value);
		}
		return builder.toString();
	}
	
	static public String makePositionMessage(Client client)
	{
		StringBuilder builder = new StringBuilder();
		builder.append(MessageType.UPDATE_PLAYER);
		builder.append(makePosition(client));
		return builder.toString();
	}
	
	static public String makeStatisticsMessage(Client client, boolean self)
	{
		StringBuilder builder = new StringBuilder();
		builder.append(MessageType.PLAYER_STATISTICS);
		builder.append(client.connectedPlayer.name);
		if(self)
		{
			builder.append(makeAttributesForSelf(client));
		}
		else
		{
			builder.append(makeAttributesForForeign(client));
		}
		builder.delete(builder.length(), builder.length() + 1);
		return builder.toString();
	}
	
	static public String makeDeletePlayerMessage(Client client)
	{
		StringBuilder builder = new StringBuilder();
		builder.append(MessageType.REMOVE_PLAYER);
		builder.append(client.connectedPlayer.name);
		return builder.toString();
	}
	
	static public String makeAddPlayerMessage(Client client)
	{
		StringBuilder builder = new StringBuilder();
		builder.append(MessageType.ADD_PLAYER);
		builder.append(makePosition(client));
		builder.append(makeAttributesForForeign(client));
		return builder.toString();
	}
}
